package cn.factory;

import cn.dao.*;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class DAOFactory {
	private static ApplicationContext ctx = null;

	static{
		ctx = new ClassPathXmlApplicationContext("springmvc-servlet.xml");
	}

	/**
	 * 返回一个用于对用户信息操作的UserDAO对象
	 * @return UserDAO
	 */
	public static UserDAO getUserDAO(){
		return (UserDAO)ctx.getBean("userdao");
	}


	/**
	 * 返回一个用于对角色信息操作的RoleDAODAO对象
	 * @return RoleDAO
	 */
	public static RoleDAO getRoleDAO(){
		return (RoleDAO)ctx.getBean("roledao");
	}

	/**
	 * 返回一个用于对申请信息操作的ApplyDAO对象
	 * @return ApplyDAO
	 */
	public static ApplyDAO getApplyDAO(){
		return (ApplyDAO)ctx.getBean("applydao");
	}

	/**
	 * 返回一个用于对教室信息操作的ClassRomeDAO对象
	 * @return ClassRomeDAO
	 */
	public static ClassRoomDAO getClassRomeDAO(){
		return (ClassRoomDAO)ctx.getBean("classromedao");
	}

	/**
	 * 返回一个用于对设备信息操作的EquipmentDAO对象
	 * @return EquipmentDAO
	 */
	public static EquipmentDAO getEquipmentDAO(){
		return (EquipmentDAO)ctx.getBean("equipmentdao");
	}

	/**
	 * 返回一个用于对设备日志信息操作的EquipmentSystemDAO对象
	 * @return EquipmentSystemDAO
	 */
	public static EquipmentLogDAO getEquipmentLogDAO(){ return (EquipmentLogDAO)ctx.getBean("logdao");
	}

	/**
	 * 返回一个用于对公告信息信息操作的NoticeDAO对象
	 * @return NoticeDAO
	 */
	public static NoticeDAO getNoticeDAO(){ return (NoticeDAO)ctx.getBean("noticedao");
	}

	/**
	 * 返回一个用于对设备维护信息信息操作的ServiceDAO对象
	 * @return ServiceDAO
	 */
	public static ServiceDAO getServiceDAO(){ return (ServiceDAO)ctx.getBean("servicedao");
	}

	/**
	 * 返回一个用于对设备借用信息信息操作的ServiceDAO对象
	 * @return BorrowDAO
	 */
	public static BorrowDAO getBorrowDAO(){ return (BorrowDAO)ctx.getBean("borrowdao");
	}

	/**
	 * 返回一个用于对系统日志信息操作的SystemLogDAO对象
	 * @return SystemLogDAO
	 */
	public static SystemLogDAO getSystemLogDAO(){
		return (SystemLogDAO)ctx.getBean("systemlogdao");
	}

	/**
	 * 返回一个用于对系统菜单信息操作的SystemModelDAO对象
	 * @return SystemModelDAO
	 */
	public static SystemModelDAO getSystemModelDAO(){
		return (SystemModelDAO)ctx.getBean("systemmodeldao");
	}

	/**
	 * 返回一个用于对角色菜单信息操作的RoleSystemModelDAO对象
	 * @return RoleSystemModelDAO
	 */
	public static RoleSystemModelDAO getRoleSystemModelDAO(){
		return (RoleSystemModelDAO)ctx.getBean("rolesystemmodel");
	}
}
